Overview
The voip function of Android is available in the directory frameworks/base/voip. It includes a package that supports rtp.
RTP support
The RTP support package is located in the directory frameworks/base/voip/java/android/net/rtp. It mainly contains four Java classes: it represents RTP-based RtpStream, RTP-based voice stream AudioStream, AudioCodec that describes the voice Codec information, and AudioGroup of The Voice session group ,.
RTP st
> 0 ){Data_size = buf_size;Len1 = avcodec_decode_audio2 (acodecctx, (int16_t *) audio_buf, data_size,Audio_pkt_data, audio_pkt_size );If (len1 /* If error, skip frame */Audio_pkt_size = 0;Break;}Audio_pkt_data + = len1;Audio_pkt_size-= len1;If (data_size /* No data yet, get more frames */Continue;}/* We have data, return it and come back for more later */Return data_size;}If (Pkt. Data)Av_free_packet ( Pkt );If (quit ){Return-1;}If (packet_queue_get ( audioq, Pkt, 1) Return-1;}Audio_pkt_data =
ID3v2Support for Podcast RSS feedsContent can be stored in files (view OS X app)Example of PCM audio that can be accessedContains a frequency analyzer (you can view Additions and iOS Apps)
2. Usage
1. Use cocoapods to install FreeStreamer.
2 Examples
# Import ViewController. h # import FSAudioStream. h @ interface ViewController () @ property (nonatomic, strong) FSAudioStream * audioStream; @ end @ implementation ViewController-(void) viewDidLoad
the application, which provides most of the required sound processing classes under this package.Let's do a play test:Import Java.io.FileInputStream;Import java.io.IOException;Import Java.io.InputStream;Import sun.audio.*;/*** Test Sound Playback** @author**/public class Musicdemo {public static void Main (string[] args) throws Exception {Create a music file input stream objectInputStream in = new FileInputStream ("Musics/flourish.mid");Creating an audio Stream objectFinal
package
Import java. Io .*;
// ** Add this into your application code as appropriate
// Open an input stream to the audio file.
Inputstream in = new fileinputstream (filename );
// Create an audiostream object from the input stream.
Audiostream as = new audiostream (in );
// Use the static class member "Player" from class audioplayer to play
// Clip.
Audiopl
1. Implement with Applet: (simplest method)
Java code AudioClip player = applet.newaudioclip (URL); AudioClip Introduction: The AudioClip interface is a simple abstraction for playing audio clips. Multiple AudioClip items can be played at the same time and the resulting sound is mixed together to produce a synthetic sound. Repeat: Player.loop ();/a sentence is done.
AudioClip player = applet.newaudioclip (URL);
AudioClip Introduction:
The AudioClip interface is a simple abstraction for
The Microphone access class provided by Windows Phone is Microsoft. Xna. Framework. Audio. Microphone, which belongs to the XNA Framework. This class is also required to access the Windows Phone Microphone in Silverlight. Therefore, you must add a reference to Microsoft. Xna. Framework.1. Declare local variables to obtain the microphone Singleton.
// Mic SingletonPrivate Microphone microphone = Microphone. Default;// Capture the audio cache each timePrivate byte [] buf;// Audio stream storage Zo
Website: http://blog.csdn.net/dadoneo/article/details/8252933From:http://www.linuxidc.com/linux/2012-04/57902.htm================================================Android is a multitasking system and the audio system is a competitive resource. Prior to Android2.2, there was no built-in mechanism to solve the problem of multiple programs competing for audio, and 2.2 introduced a mechanism called Audiofocus to manage and coordinate the competition for audio resources. This article mainly explains th
How can I determine whether the system is playing an alarm?
There is an isMusicActive () method in AudioManager to determine whether the current music is being played.
What about the alarm? No related APIs are found.
Two solutions:
1. Add a method to AudioManager and modify the source code. You can refer to Android to get the third-party alert message.
2. reflection.
Reflection solution:
/** * Unhide android api: check is stream is active now (AudioManager.STREAM_RING, AudioManager.STREAM_NOTIF
();Return}Auline.start ();int nbytesread = 0;It's a buffer.byte[] Abdata = new byte[512];try {while (Nbytesread!=-1) {Nbytesread = Audioinputstream.read (abdata, 0, abdata.length);if (nbytesread >= 0)Auline.write (abdata, 0, Nbytesread);}catch (IOException e) {E.printstacktrace ();Returnfinally {Auline.drain ();Auline.close ();}}}
The following is a Java application that plays sound, which can play the sound one time and loop the sound
Musicpaly mymusicplay = new Musicplay (GetClass (). Get
+ "\sounds\1\1.mp3" is the URI of the file itself, where the SOUNDS/1 folder is a demonstration, representing any path dropping under the bin. Notice that the backslash is replaced by a double backslash.We pass this path (String name) to FileInputStream and get the resource file we want to play audiostream.Next is the playback code:Audiostream as = new Audiostream (Fileau);AudioPlayer.player.start (AS);Suppose we use a URL to locate a resource file t
(String args[]) { try { FileInputStream fileau=new FileInputStream("sloop.au"); AudioStream as=new AudioStream(fileau); AudioPlayer.player.start(as); } catch (Exception e) {} } }
Note: Neither of the above offers the corresponding Stop method, this article refers to the attempt in the method, not a comprehensive article, but the above examples are available.
Application of sound package in three javax
As
next chapter, it is no longer difficult to add this part of code to refresh the correct image at the right time.Simplified codeWe need to trim the code. We have all audio and video codec information, and we also need to add queues, buffers, and otherEverything is a logical unit service-movie, so we should create a large struct to put all this informationIncluded, named videostateTypedef struct videostate {
Avformatcontext * pformatctx;Int videostream, aud
Package com. Sunray. Express. Core. util;
Import java. Io. bufferedinputstream;Import java. Io. file;Import java. Io. fileinputstream;Import java. Io. ioexception;
Import sun. Audio. audioplayer;Import sun. Audio. audiostream;
Public class playaudio1 {
Static bufferedinputstream Buf;
Public static void start () // This is to read the sound file through the stream{Try {File dir = new file ("E: \ music \ YH \ WAV"); // the path of the file to be playedF
This article focuses on playing the video sound.
audioStream = -1; for (i = 0; i
The above code mainly finds the first audio stream.
aCodecCtx=pFormatCtx->streams[audioStream]->codec;
Record the context information of an audio decoder.
wanted_spec.freq = aCodecCtx->sample_rate;wanted_spec.format = AUDIO_S16SYS;wanted_spec.channels = aCodecCtx->channels;wanted_spec.silence = 0;wanted_spec.samples = SDL
1. Unable to find a suitable output format for error:
Because no call
Av_register_all ();
Check whether other initialization functions are not called.
2.
Avcodec_encode_audio (audiostream-> codec,Audiobuffer, audio_buffer_size, frame. Data. bytes); there is no input parameter to describe the length of the original frame, which means that the length of the original audio frame is fixed by default when FFmpeg is encoding the audio.
ability to record sound is very useful in situations where you need to say, record a phone conversation. to use the sound recording capability in the SDF, add a reference to the opennetcf. dll library in your project. declare the following variables:
'---for audio recording--- Private audioRecorder As OpenNETCF.Media.WaveAudio.Recorder '---duration to record (in seconds)--- Const RECORD_DURATION As Integer = 10000To record voice, first open a file for voice recording and then use
How to read a sound file in 1,java:
String wavename = "Voice.wav"; try {inputstream ws = GamePanel.class.getResourceAsStream (wavename); Audiostream as = new Audiostream (WS); AudioPlayer.player.start (AS); catch (Exception e) {System.out.println (E.getmessage ());}
2, configure the GlassFish jndi data source in spring:
The configuration process is simple, first login GlassFish background, resource-jdbc-
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.